package com.hecore.lagou.speak;


import com.hecore.lagou.speak.component.SpeakMapper;
import com.hecore.lagou.speak.component.SpeakReducer;
import com.hecore.lagou.speak.entity.SpeakBean;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @Author: hecore
 * @Date: 2020/10/18 20:05
 * @Description:
 */

public class SpeakDriver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        final Configuration config=new Configuration();
        Job job=Job.getInstance(config,"dirver");
        setJobConfig(job);
        // param
        // 1.3 in&out set
        FileInputFormat.setInputPaths(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));
        boolean result=job.waitForCompletion(true);
        System.exit(result?0:1);

    }

    private static void setJobConfig(Job job) {
        // jar set
        job.setJarByClass(SpeakDriver.class);
        // mapper&reducer set
        job.setMapperClass(SpeakMapper.class);
        job.setReducerClass(SpeakReducer.class);
        //map out set
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(SpeakBean.class);
        // final out set
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(SpeakBean.class);
    }

}
